package com.ag.improvedjava.iterable;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.ag.improvedjava.utils.Grouping;

final class GroupingImpl<K, V> implements Grouping<K, V> {

	private final K key;
	private final List<V> values;
	
	GroupingImpl(K key, List<V> values) {
		this.key = key;
		this.values = values;
	}
	
	@Override
	public K key() {
		return key;
	}
	
	@Override
	public Iterator<V> iterator() {
		return values.iterator();
	}

	@Override
	public List<V> values() {
		return new ArrayList<>(values);
	}
}

	